<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>消息列表</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="//cdn.bootcss.com/weui/0.4.3/style/weui.min.css">
		<link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/0.8.3/css/jquery-weui.min.css">
		<link rel="stylesheet" href="../css/index.css" />
		<style>
			ul li b span{
				width: 8px;
				height: 8px;
				background-color: #04BE02;
				border-radius: 10px;
				display: block;
				float: left;
				margin-top: 7.5px;
				margin-left: 5px;
			}
			em{
				font-style: normal;
				float: left;
			}
		</style>
	</head>
	<body id="newslist">
		<ul>
			<!--<li>
				<b>专属消息</b>
				<strong>2017-12-21 12:35</strong>
				<p>公司为了回馈老用户支持公司为了回馈老用户支持公司为了回馈老用户支持</p>
			</li>
			<li>
				<b>专属消息</b>
				<strong>2017-12-21 12:35</strong>
				<p>公司为了回馈老用户支持公司为了回馈老用户支持公司为了回馈老用户支持</p>
			</li>
			<li>
				<b>专属消息</b>
				<strong>2017-12-21 12:35</strong>
				<p>公司为了回馈老用户支持公司为了回馈老用户支持公司为了回馈老用户支持</p>
			</li>
			<li>
				<b>专属消息</b>
				<strong>2017-12-21 12:35</strong>
				<p>公司为了回馈老用户支持公司为了回馈老用户支持公司为了回馈老用户支持</p>
			</li>-->
		</ul>
		
		<div class="weui-infinite-scroll loading">
			  <div class="infinite-preloader"></div>
			  正在加载中... 
		</div>
		<script src="//cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
		<script src="//cdn.bootcss.com/jquery-weui/0.8.3/js/jquery-weui.min.js"></script>
		<script type="text/javascript" src="../js/basic.js" ></script>
		<script>
			var ip_addr = getUrl();
			var pageNo = 1;
			var pageSize = 8;
			var loading = false;
			$(document).ready(function() {
				messagelist();
				$("#newslist").infinite().on("infinite", function() {
					 if(loading) return;
					  loading = true;
					  setTimeout(function() {
					    pageNo++; 
					    messagelist();
					    loading = false;
					  }, 800); 
				});
			});
			//消息列表接口
			function messagelist() {
				var type = GetQueryString("type")
				$.ajax({
					type: 'post',
					dataType: "json",
					url: ip_addr + 'message/list',
					data: {
						pageNo: pageNo,
						pageSize: pageSize
					},
					success: function(data) {
						var result = data.rows;
						var innerHTML = '';
						if(data.total <= pageNo*pageSize){
							loading = true;
							$(".loading").hide();
						}else{
							loading = false;
						}
						if(data.total < 8){
							$(".loading").hide();
						}
						if(data.code == 0) {
							for(var i = 0; i < result.length; i++) {
								innerHTML += '<a href="newsListdetails.html?id='+result[i].id+'">';
								innerHTML += '<li>';
								innerHTML += '<b>';
								innerHTML += '<em>专属消息</em>';
								if(result[i].isread == 0){
									innerHTML += '<span></span>';
								}
								innerHTML += '</b>';
								innerHTML += '<strong>'+formatDateM(result[i].updateTime)+'</strong>';
								innerHTML += '<p>'+result[i].name+'</p>';
								innerHTML += '</li>';
								innerHTML += '</a>';
							}
							$("#newslist ul").append(innerHTML);
						} else {
							$.alert({
							  title: '温馨提示',
							  text: '很抱歉，您还未登录，请登录!',
							  onOK: function () {
							   window.location.href = 'wode.html?type=1';
							  }
							});
						}
					}
				});
			}
			
			
			var referUrl='property.html';
			pushHistory(referUrl);//微信苹果返回刷新
			/*点击微信返回时，会刷新*/
			function pushHistory(referUrl){ window.addEventListener("popstate",function(e){
			  location.href=referUrl;
			 }, false);
			 var state = {
			   title:''
			 };
			 var title='';
			 var url='';
			 window.history.pushState(state,title,url);
			}
			
		</script>
	</body>
</html>
